package com.ds.infrastructure.audit.admin.security;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.stereotype.Component;

/**
 * 作用：
 *
 * @author WeiShaoying
 * @date 2020/8/10
 */
@Component
@ConditionalOnProperty(name = "sso.enable", havingValue = "false")
@Slf4j
public class DisableSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity httpSecurity) throws Exception {
        log.info("权限已禁用");
        httpSecurity.authorizeRequests()
                //.antMatchers("/admin/**").authenticated()
                .antMatchers("/**").permitAll()
                .and()
                .csrf().disable();
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        //auth.inMemoryAuthentication().withUser(AdminConstant.ADMIN_DEFT).roles(Role.ROLE_ADMIN.name());
    }
}
